package leetcode.leetcode_3005;

import java.util.Collection;
import java.util.HashMap;

class Solution {
    public int maxFrequencyElements(int[] nums) {
//        使用Map存储每个值的出现次数
        HashMap<Integer, Integer> map = new HashMap<>();
        int maxx = 0;
        for (int i :nums){
            int num = map.getOrDefault(i,0);
            map.put(i,num+1);
            maxx = Math.max(maxx,num+1);
        }
        Collection<Integer> values = map.values();
        int ans = 0;
        for (int i : values){
            if (i == maxx) {
                ans++;
            }
        }
        return ans;
    }
}